<template>
  <div class="home">
    <home-header></home-header>
    <home-swiper :swipersList="swipersList"></home-swiper>
    <home-icons :iconsList="iconsList"></home-icons>
    <home-recommend :recommendList="recommendList"></home-recommend>
    <home-weekend :weekendList="weekendList"></home-weekend>
  </div>
</template>

<script>
// @ is an alias to /src
import homeHeader from "@/components/common/header.vue";
import homeSwiper from "@/components/common/swiper.vue";
import homeIcons from "@/components/common/icons.vue";
import homeRecommend from "@/components/common/recommend.vue";
import homeWeekend from "@/components/common/weekend.vue";

export default {
  name: "home",
  data() {
    return {
      iconsList: [],
      swipersList: [],
      recommendList: [],
      weekendList: []
    };
  },
  components: {
    homeHeader,
    homeSwiper,
    homeIcons,
    homeRecommend,
    homeWeekend
  },
  methods: {
    getHomeData() {
      this.$axios.get("/api/home.json").then(res => {
        console.log(res);
        var val = res.data;
        if (val.ret && val.data) {
          this.iconsList = val.data.iconsList;
          this.swipersList = val.data.swipersList;
          this.recommendList = val.data.recommendList;
          this.weekendList = val.data.weekendList;
        }
      });
    }
  },
  mounted() {
    this.getHomeData();
  }
};
</script>
